package com.taotao.order.dao;

import org.springframework.beans.factory.annotation.Autowired;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class JedisClientSig implements JedisClient {
	@Autowired
	private JedisPool redisPool;
	@Override
	public String get(String key) {
		Jedis redisClient = redisPool.getResource();
		String string = redisClient.get(key);
		redisClient.close();
		return string;
	}

	@Override
	public String set(String key, String value) {
		Jedis redisClient = redisPool.getResource();
		String string = redisClient.set(key, value);
		redisClient.close();
		return string;
	}

	@Override
	public String hget(String hkey, String key) {
		Jedis redisClient = redisPool.getResource();
		String hget = redisClient.hget(hkey, key);
		redisClient.close();
		return hget;
	}

	@Override
	public long hset(String hkey, String key, String value) {
		Jedis redisClient = redisPool.getResource();
		Long hset = redisClient.hset(hkey, key, value);
		redisClient.close();
		return hset;
	}

	@Override
	public long incr(String key) {
		Jedis redisClient = redisPool.getResource();
		Long incr = redisClient.incr(key);
		redisClient.close();
		return incr;
	}

	@Override
	public long expire(String key, int second) {
		Jedis redisClient = redisPool.getResource();
		Long expire = redisClient.expire(key, second);
		redisClient.close();
		return expire;
	}

	@Override
	public long ttl(String key) {
		Jedis redisClient = redisPool.getResource();
		Long ttl = redisClient.ttl(key);
		redisClient.close();
		return ttl;
	}

	@Override
	public long del(String key) {
		// TODO Auto-generated method stub
		Jedis redisClient = redisPool.getResource();
		long del = redisClient.del(key);
		redisClient.close();
		return del;
	}

	@Override
	public long hdel(String hkey, String key) {
		// TODO Auto-generated method stub
		Jedis redisClient = redisPool.getResource();
		long hdel = redisClient.hdel(hkey, key);
		return hdel;
	}

}
